package com.dayatang.android.config;

import android.content.Context;
import android.content.pm.PackageManager.NameNotFoundException;
import android.util.Log;

import com.dayatang.android.Activity.R;

public class Config {
	
	private static final String TAG = "Config";
	
	public static final int ZERO = 0;
	public static final int ONE = 1;
	public static final int TWO = 2;
	public static final int THREE = 3;
	public static final int FOUR = 4;
	public static final int EIGHT = 8;
	
	public static final String COMMONDATA = "commonData";
	public static final String OK = "ok";
	public static final String SERVERDIE = "serverDie"; 
	public static final String SERVERADDRESS = "serverAddress"; 
	public static final String INIT = "init"; 
	public static final String SETTINGS = "settings";
	public static final String WHERE = "where";
	public static final String LOGOUT = "logout";
	public static final String RESETSERVERADDRESS = "resetServerAddress";
	public static final String DBNAME = "proj_mgmt.db";
	public static final String USERNAMENOEXISTS = "usernameNoExists";
	public static final String PASSWORDERROR = "passwordError";
	public static final String ERROR = "error";
	public static final String OTHER = "other";
	public static final String APPNAME = "proj-mgmt-android.apk";
	public static final String NO = "no";
	public static final String UPDATE = "update";
	public static final String ROOTDIR = "/proj-mgmt/";
	public static final String PROJNAME = "projName";
	public static final String URL = "url";
	public static final String BYNAME = "byname";
	public static final String NODATA = "NoData";
	public static final String UTF = "UTF-8";
	public static final String PMO = "pmo";
	public static final String USER = "user";
	public static final String PROJID = "projectid";
	public static final String SUBPROJID = "subprojectid";
	public static final String RED = "red";
	public static final String WHITE = "white";
	public static final String FROMWHERE = "fromwhere";
	public static final String SUBPROJECTID = "subprojectid";
	
	public static int getVerCode(Context context) {
		int verCode = -1;
		try {
			verCode = context.getPackageManager().getPackageInfo(
					context.getPackageName(), 0).versionCode;
		} catch (NameNotFoundException e) {
			Log.e(TAG, e.getMessage());
		}
		return verCode;
	}

	public static String getVerName(Context context) {
		String verName = "";
		try {
			verName = context.getPackageManager().getPackageInfo(
					context.getPackageName(), Config.ZERO).versionName;
		} catch (NameNotFoundException e) {
			Log.e(TAG, e.getMessage());
		}
		return verName;
	}

	public static String getAppName(Context context) {
		String verName = context.getResources().getText(R.string.app_name)
				.toString();
		return verName;
	}

}
